/*
 * 机械设备列表
 * @Author: zfx
 * @Date: 2018-07-02 15:53:05
 */
<style lang="less" rel="stylesheet/less" type="text/less" scoped>

</style>
<template>
	<div>
		<Table
			:columns="columns"
			:loading="loading"
			:data="machineDevices"
			:height="tableHeight(2)"
			class="personal-scrollbar"
			border />

	</div>
</template>

<script>

import Button from 'iview/src/components/button';
import { computedTableHeight } from 'src/views/mixins/computedTableHeight'; // 引入mixins文件

export default {

	name: 'MechanicalIndex',
	mixins: [computedTableHeight],
	props: {
		loading: {
			type: Boolean,
			default() {
				return false;
			},
		},
		machineDevices: {
			type: Array,
			default() {
				return [];
			},
		},
		skinDetectors: {
			type: Object,
			default() {
				return {};
			},
		},
	},

	data() {
		return {
			columns: [
				{
					title: this.$t('equipment.code'),
					key: 'code',
					align: 'center',
					render: (h, { row }) => <div> { row.code || '-' } </div>,
				},
				{
					title: this.$t('equipment.device_name'),
					key: 'device_name',
					align: 'center',

					render: (h, { row }) => <div> { row.device_name || '-' } </div>,
				},
				{
					title: this.$t('equipment.specification'),
					key: 'specification',
					align: 'center',
					render: (h, { row }) => <div> { row.specification || '-' } </div>,
				},
				{
					title: this.$t('equipment.producer'),
					key: 'producer',
					align: 'center',
					render: (h, { row }) => <div> { row.producer || '-' } </div>,
				},
				{
					title: this.$t('equipment.device_spec'),
					key: 'device_spec_id',
					align: 'center',
					width: 180,
					render: (h, { row }) => <div> { !row.device_spec ? '无' : row.device_spec.code } </div>,
				},
				{
					title: this.$t('common.operation'),
					align: 'center',
					width: 180,
					render: (h, { row }) => (
						<div>
							<Button size="small" on-click={() => { this.$emit('show', row); }} type="primary">
								{this.$t('common.edit')}
							</Button>
						</div>
					),
				},

			],
		};
	},
};
</script>
